<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Codec - GIAnT API</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="GIAnT API" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/Atom.html">Atom</a></li>
                                <li><a href="../classes/Codec.html">Codec</a></li>
                                <li><a href="../classes/Constraints.html">Constraints</a></li>
                                <li><a href="../classes/Database.html">Database</a></li>
                                <li><a href="../classes/Exif.html">Exif</a></li>
                                <li><a href="../classes/Export.html">Export</a></li>
                                <li><a href="../classes/Heatmap.html">Heatmap</a></li>
                                <li><a href="../classes/Server.html">Server</a></li>
                                <li><a href="../classes/Settings.html">Settings</a></li>
                                <li><a href="../classes/Utils.html">Utils</a></li>
                            </ul>
                
                
                            <ul id="api-modules" class="apis modules">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1>Codec Class</h1>
<div class="box meta">


        <div class="foundat">
            Defined in: <a href="../files/src_codec.js.html#l1"><code>src\codec.js:1</code></a>
        </div>


</div>


<div class="box intro">
    <p>This class converts the Editor's XML format into a flat javascript format
which is inserted into the Neo4j database.</p>
<pre class="code prettyprint"><code> 1. Load XML
 2. Add all nodes as children to the layers (unpack the &lt;mxCell&gt; from the &lt;object&gt; tag)
     the &lt;object&gt; tag is used to wrap an mxCell with its attributes
 3. Remove groups
 4. Edges (There will be no edge without token -&gt; drop layer information)
     - edges don't work inter groups, but they can be intra groups
         -&gt; they have to be unwrapped as well
 5. Flatten the hierarchical tree
     - merge mxCells with their layers to obtain the layer-attributes
 6. Collect all possible attributes

 (1) Drop following attributes

 - Graph
     - grid
     - gridSize
     - guides
     - toolTips
     - connect
     - arrows
     - fold
     - page
     - pageScale


 (2) Parse the style attribute in order to retrieve the following attributes

  - MxCell
     - tokenType


  -&gt; first: read the saved mxgraph with xml2js into a javscript object
  -&gt; then make the validity checks
     - is the structure of the xml correct
         - mxGraph
             - root
                 - cell
                     - geometry
                 - object
                     - cell
                         - geometry

     - are all necessary attributes at hand
         - mxGraphModel
             - dx
             - dy
             - pageWidth
             - pageHeight
         - mxCell
             - id
             - parent
  -&gt; then drop unnecessary attributes
  -&gt; export as GraphML (http://graphml.graphdrawing.org/primer/graphml-primer.html)


 This class was developed by Test Driven Development.</code></pre>

</div>


<div id="classdocs" class="tabview">
    <ul class="api-class-tabs">
        <li class="api-class-tab index"><a href="#index">Index</a></li>

            <li class="api-class-tab methods"><a href="#methods">Methods</a></li>
            <li class="api-class-tab properties"><a href="#properties">Properties</a></li>
    </ul>

    <div>
        <div id="index" class="api-class-tabpanel index">
            <h2 class="off-left">Item Index</h2>

                <div class="index-section methods">
                    <h3>Methods</h3>

                    <ul class="index-list methods">
                            <li class="index-item method">
                                <a href="#method_add_all_completed_fragments_to_neo4j">add_all_completed_fragments_to_neo4j</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_node_by_id">get_node_by_id</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_get_nodes_by_parent_id">get_nodes_by_parent_id</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_mxgraph_to_flattened_object">mxgraph_to_flattened_object</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_mxgraph_to_graphml">mxgraph_to_graphml</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_mxgraph_to_layered_object">mxgraph_to_layered_object</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_mxgraph_to_neo4j">mxgraph_to_neo4j</a>

                            </li>
                            <li class="index-item method">
                                <a href="#method_mxgraph_to_object">mxgraph_to_object</a>

                            </li>
                    </ul>
                </div>

                <div class="index-section properties">
                    <h3>Properties</h3>

                    <ul class="index-list properties">
                            <li class="index-item property">
                                <a href="#property_builder">builder</a>

                            </li>
                            <li class="index-item property">
                                <a href="#property_parser">parser</a>

                            </li>
                    </ul>
                </div>


        </div>

            <div id="methods" class="api-class-tabpanel">
                <h2 class="off-left">Methods</h2>

<div id="method_add_all_completed_fragments_to_neo4j" class="method item">
    <h3 class="name"><code>add_all_completed_fragments_to_neo4j</code></h3>

        <span class="paren">()</span>

        <span class="returns-inline">
            <span class="type">Promise</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l451"><code>src\codec.js:451</code></a>
        </p>



    </div>

    <div class="description">
        <p>Adds all fragments that have the flag completed set to true to the database
There is SHA1 hash comparing done here in order to eliminate unnecessary computations.</p>

    </div>


        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Promise</span>:
            </div>
        </div>


</div>
<div id="method_get_node_by_id" class="method item">
    <h3 class="name"><code>get_node_by_id</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>root</code>
                </li>
                <li class="arg">
                        <code>id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Node</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l186"><code>src\codec.js:186</code></a>
        </p>



    </div>

    <div class="description">
        <p>Works on a mxGraph xml2js-object
Finds a node given an id</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">root</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>mxGraph tree</p>

                    </div>

                </li>
                <li class="param">
                        <code class="param-name">id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Node</span>:
            </div>
        </div>


</div>
<div id="method_get_nodes_by_parent_id" class="method item">
    <h3 class="name"><code>get_nodes_by_parent_id</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>root</code>
                </li>
                <li class="arg">
                        <code>parent_id</code>
                </li>
            </ul><span class="paren">)</span>
        </div>

        <span class="returns-inline">
            <span class="type">Array</span>
        </span>







    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l204"><code>src\codec.js:204</code></a>
        </p>



    </div>

    <div class="description">
        <p>Works on a mxGraph xml2js-object
Gets all nodes with a given parent</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">root</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">parent_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>

        <div class="returns">
            <h4>Returns:</h4>

            <div class="returns-description">
                        <span class="type">Array</span>:
            </div>
        </div>


</div>
<div id="method_mxgraph_to_flattened_object" class="method item">
    <h3 class="name"><code>mxgraph_to_flattened_object</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>filename</code>
                </li>
            </ul><span class="paren">)</span>
        </div>








    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l258"><code>src\codec.js:258</code></a>
        </p>



    </div>

    <div class="description">
        <p>Converts an mxGraph to a flat object structured as follows</p>
<p>graph.mxGraphModel.data.token1
graph.mxGraphModel.data.token2
graph.mxGraphModel.data.edge1</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">filename</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>



</div>
<div id="method_mxgraph_to_graphml" class="method item">
    <h3 class="name"><code>mxgraph_to_graphml</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>filename</code>
                </li>
            </ul><span class="paren">)</span>
        </div>








    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l303"><code>src\codec.js:303</code></a>
        </p>



    </div>

    <div class="description">
        <p>Converts a mxGraph into the GraphML format</p>
<p>It removes groups and is not necessary for the code
Only nice to have</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">filename</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>



</div>
<div id="method_mxgraph_to_layered_object" class="method item">
    <h3 class="name"><code>mxgraph_to_layered_object</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>filename</code>
                </li>
            </ul><span class="paren">)</span>
        </div>








    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l225"><code>src\codec.js:225</code></a>
        </p>



    </div>

    <div class="description">
        <p>Converts the mxGraph to an object structured ad follows</p>
<p>obj.mxGraphModel.layer1.node1</p>
<p>It removes groups</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">filename</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
            </ul>
        </div>



</div>
<div id="method_mxgraph_to_neo4j" class="method item">
    <h3 class="name"><code>mxgraph_to_neo4j</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>image_id</code>
                </li>
                <li class="arg">
                        <code>fragment_id</code>
                </li>
                <li class="arg">
                        <code>overwrite_xml_path</code>
                </li>
            </ul><span class="paren">)</span>
        </div>








    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l497"><code>src\codec.js:497</code></a>
        </p>



    </div>

    <div class="description">
        <p>Loads an mxGraph over the flat xml2js-object into the neo4j database</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">image_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">fragment_id</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                         
                    </div>

                </li>
                <li class="param">
                        <code class="param-name">overwrite_xml_path</code>
                        <span class="type">Object</span>


                    <div class="param-description">
                        <p>if you don't want to load the standard xml file_path for the fragment use this</p>

                    </div>

                </li>
            </ul>
        </div>



</div>
<div id="method_mxgraph_to_object" class="method item">
    <h3 class="name"><code>mxgraph_to_object</code></h3>

        <div class="args">
            <span class="paren">(</span><ul class="args-list inline commas">
                <li class="arg">
                        <code>filename</code>
                </li>
            </ul><span class="paren">)</span>
        </div>








    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l94"><code>src\codec.js:94</code></a>
        </p>



    </div>

    <div class="description">
        <p>Parses the mxGraph XML file into a javascript object</p>

    </div>

        <div class="params">
            <h4>Parameters:</h4>

            <ul class="params-list">
                <li class="param">
                        <code class="param-name">filename</code>
                        <span class="type">Promise</span>


                    <div class="param-description">
                        <p>the resource to load
return</p>

                    </div>

                </li>
            </ul>
        </div>



</div>
            </div>

            <div id="properties" class="api-class-tabpanel">
                <h2 class="off-left">Properties</h2>

<div id="property_builder" class="property item">
    <h3 class="name"><code>builder</code></h3>
    <span class="type">Object</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l82"><code>src\codec.js:82</code></a>
        </p>


    </div>

    <div class="description">
        <p>The xml2js builder</p>
<p>This object can create xml files</p>

    </div>



</div>
<div id="property_parser" class="property item">
    <h3 class="name"><code>parser</code></h3>
    <span class="type">Object</span>





    <div class="meta">
                <p>
                Defined in
        <a href="../files/src_codec.js.html#l74"><code>src\codec.js:74</code></a>
        </p>


    </div>

    <div class="description">
        <p>The xml2js parser</p>

    </div>



</div>
            </div>


    </div>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
